//
//   Copyright (c) 2009 Bálint Jánvári
//       www.programmaticmagic.com
//  
//  Permission is hereby granted, free of charge, to any person
//  obtaining a copy of this software and associated documentation
//  files (the "Software"), to deal in the Software without
//  restriction, including without limitation the rights to use,
//  copy, modify, merge, publish, distribute, sublicense, and/or sell
//  copies of the Software, and to permit persons to whom the
//  Software is furnished to do so, subject to the following
//  conditions:
//
//  The above copyright notice and this permission notice shall be
//  included in all copies or substantial portions of the Software.
//
//  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
//  EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
//  OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
//  NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
//  HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
//  WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
//  FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
//  OTHER DEALINGS IN THE SOFTWARE.

//
//  OMTextDialog.h
//  ObjectiveMagic
//

#import <Foundation/Foundation.h>

/*
 OMTextDialog simplifies the creation and display of a UIAlertView
 with a UITextField. The resulting dialog will resemble standard text
 input dialogs Apple uses in other applications.
 */

@class OMTextDialog;

// All delegate methods are optional - however, as the point of this dialog
// is to provide a way to enter text, most implementations should implement
// at least textDialog:willFinishWithText: or textDialog:didFinishWithText:
@protocol OMTextDialogDelegate<NSObject>
@optional
- (void)textDialogWillShow:(OMTextDialog*)dialog;
- (void)textDialogDidShow:(OMTextDialog*)dialog;
- (void)textDialog:(OMTextDialog*)dialog didFinishWithText:(NSString*)text;
- (void)textDialog:(OMTextDialog*)dialog willFinishWithText:(NSString*)text;
- (void)textDialogWillCancel:(OMTextDialog*)dialog;
- (void)textDialogDidCancel:(OMTextDialog*)dialog;
@end

@interface OMTextDialog : NSObject<UIAlertViewDelegate, UITextFieldDelegate> {
	NSString* message;
	NSString* title;
	BOOL password;
	BOOL isVisible;
	id<OMTextDialogDelegate> delegate;
	UIAlertView* currentAlertView;
}
@property(readonly, nonatomic) BOOL isVisible; // YES if the dialog is visible
@property(assign, nonatomic) BOOL password; // Sets the textfield's secureTextEntry property
@property(copy, nonatomic) NSString* title;
@property(copy, nonatomic) NSString* message;
@property(assign, nonatomic) id<OMTextDialogDelegate> delegate;
- (id)initWithTitle:(NSString*)title message:(NSString*)message delegate:(id<OMTextDialogDelegate>)delegate;
- (id)initWithTitle:(NSString*)title message:(NSString*)message password:(BOOL)yesOrNo delegate:(id<OMTextDialogDelegate>)delegate;
- (void)show;
- (void)dismissWithText:(NSString*)text;
@end
